# -*- coding: utf-8 -*-
from seekfree import TIMER
from seekfree import GPIO

def timer_callback(s):
    print(s.count())
    pinph2.toggle()

TIMER.help()                            # 模块使用说明

tim = TIMER(1000)                       # 初始化 TIMER 定时器 周期 1000ms
tim.callback(timer_callback)            # 设置回调函数
# tim.enable()
# tim.disable()
tim.info()                              # 模块参数输出

pinph2 = GPIO(0x72, 1, 1)               # H2 输出 推完输出高
pinpg2 = GPIO(0x62, 0, 1)               # G2 输入 上拉
pinpg3 = GPIO(0x63, 0, 1)               # G3 输入 上拉
num = 0
dir = 1
duty = 0

while 1:
    if pinpg2.value() == 0:             # 按下按键 G2
        tim.count(0)                    # 清空定时器计数

    if pinpg3.value() == 0:             # 按下按键 G3
        print("Exti TIMER test program.\n")
        break                           # 退出测试程序 （如果接下来要运行其他代码请先退出本测试程序）
